import homeConfig from './homeConfig.js'

let homeRoutes = []

for (let path in homeConfig) {
  //   let paths = path.split('/')
  //   console.log(paths)
  //   console.log(path.replace(/^\/home/, '').replace(/\//g, ''))

  homeRoutes.push({
    path: path,
    name: path.replace(/^\/home/, '').replace(/\//g, ''),
    component: homeConfig[path],
  })
}

homeRoutes.push({
  path: '/home/auth',
  component: () => import('@/views/AuthView.vue'),
})
homeRoutes.push({
  path: '/home/:error(.*)*',
  component: () => import('@/views/NotFound.vue'),
})

export default [
  {
    path: '/',
    redirect: '/login',
    meta: {
      isPublic: true,
    },
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/LoginView.vue'),
    meta: {
      isPublic: true,
    },
  },
  {
    path: '/home',
    name: 'home',
    component: () => import('@/views/HomeView.vue'),
    children: homeRoutes,
  },
  {
    path: '/:error(.*)*',
    // component:()=>import("@/views/NotFound.vue")
    redirect: '/login',
    meta: {
      isPublic: true,
    },
  },
]
